package cn.chencaiju.day03;

import org.junit.Test;

public class CanPlantFlower {
	public boolean canPlantFlower(int[] flowers,int n) {
		int count=0;
		for(int i=0;i<flowers.length;i++) {
			if(flowers[i]==1) {
				continue;
			}
			else {
				if((i==0||flowers[i-1]==0)&&(i==flowers.length-1||flowers[i+1]==0)) {
					flowers[i]=1;
					count++;
				}
			}
		}
		return count>=n;	
		
	}
	@Test public void testCanPlantFlower() {
		int[] flowers= {0,0,1,0,0,1,0,0,0,0};
		System.out.println(canPlantFlower(flowers,4));
	}
}
